package com.hunttown.mes.dao;

import com.hunttown.common.dao.base.BaseDao;
import com.hunttown.common.domain.Query;
import com.hunttown.mes.domain.TransportUserCard;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * created by wangjunfu on 2021-02-24 16:00:12
 */
@Repository
public class TransportUserCardDao extends BaseDao {
    private static final Logger logger = LoggerFactory.getLogger(TransportUserCardDao.class);

    public TransportUserCard insert(final TransportUserCard transportUserCard) {
        insert("TransportUserCard.insert", transportUserCard);
        return transportUserCard;
    }

    public Boolean updateInfoById(final TransportUserCard transportUserCard) {
        return update("TransportUserCard.updateInfoById", transportUserCard) > 0;
    }

    public Boolean updateInfoByQuery(final Query query) {
        return update("TransportUserCard.updateInfoByQuery", query) > 0;
    }

    public TransportUserCard selectById(final Integer id, final Integer entId) {
        Query query = Query.noPage();
        query.put("id", id);
        query.put("entId", entId);
        return queryForObject("TransportUserCard.selectById", query);
    }

    public List<TransportUserCard> selectByQuery(final Query query) {
        return queryForList("TransportUserCard.selectByQuery", query);
    }

    public Long countByQuery(final Query query) {
        return queryForObject("TransportUserCard.countByQuery", query);
    }

    public Boolean deleteById(final Integer id, final Integer entId) {
        TransportUserCard transportUserCard = new TransportUserCard();
        transportUserCard.setDeleteFlag(1);
        transportUserCard.setId(id);
        transportUserCard.setEntId(entId);

        return update("TransportUserCard.updateInfoById", transportUserCard) > 0;
    }

    //物理删除不可恢复，慎用！
    public Boolean deleteByIdForPhysical(final Integer id) {
        Query query = Query.noPage();
        query.put("id", id);
        return delete("TransportUserCard.deleteById", query) > 0;
    }
}